<script>
    $(document).on('click','.btn-confirm', function () {
        var formData = $(this).data();
                {{--请求数据--}}
        var reloadUrl = $(this).data('reloadUrl');
        var requestUrl = $(this).data('requestUrl');
        var promiseType = $(this).data('promiseType');
        var title = $(this).data('title');
        var title = $(this).data('title');
        var method = $(this).data('method');
        swal({
            title: title,
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定",
            showLoaderOnConfirm: true,
            cancelButtonText: "取消",
            preConfirm: function () {
                return new Promise(function (resolve) {
                    switch (promiseType) {
                        case 'ajax':
                        default:
                            $.ajax({
                                method: method ||'GET',
                                url: requestUrl,
                                data: formData,
                                success: function (data) {
                                    $.pjax({url: reloadUrl, container: '#pjax-container'});
                                    resolve(data);
                                }
                            });
                    }
                });
            }
        }).then(function (result) {
            var data = result.value;
            if (typeof data === 'object') {
                if (data.status == 2000) {
                    swal(data.msg, '', 'success');
                } else {
                    swal(data.msg, '', 'error');
                }
            }
        });
    });
</script>